﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class dyyyqy : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "print")
        {
            ////获取表中记录主键的方法
            //int id = Convert.ToInt32(e.CommandArgument);

             //获取gridview行号
            int index = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

            string sss = "";

            sss= "'" + GridView1.Rows[index].Cells[0].Text + ":','" + GridView1.Rows[index].Cells[1].Text + "'";
            
            using (DataClassesDataContext mydata = new DataClassesDataContext())
            {
                var query1 = from q in mydata.system_info
                             select q;
                if (query1 != null)
                {
                    foreach (var rd1 in query1)
                    {
                        sss = sss + ",'" + rd1.wangzhi + "','" + rd1.huanbaobumen + "','" + rd1.jishuzhichidianhua + "'";
                    }
                }
                else
                {

                }
            }                    
           
            //// 得到当前选定行的某单元格 的值           
            //Response.Write("<script>alert('" + GridView1.Rows[index].Cells[1].Text + "')</script>");
            //调用tk()
            ClientScript.RegisterStartupScript(this.GetType(), "myscript", "<script type='text/javascript'>Print(" + sss + ");</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox2.Text.Trim() != "")
        {
            using (DataClassesDataContext mydata = new DataClassesDataContext())
            {
                var query2 = from q in mydata.qiyejibenxingxi
                            where q.dwmc.Contains(TextBox2.Text.Trim())
                            select q;
                GridView1.DataSource = query2;
                GridView1.DataBind();
            }
        }
    }
}